<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>计算器</title>
</head>

<body>
    数字1<input type="text" name="num1" id="num1">
    符号<input type="text" name="sig" id="sig">
    数字2<input type="text" name="num2" id="num2">
    <input type="button" value="计算" onclick="calc()"><br>
    结果<input type="text" name="res" id="res">

    <script src="./jquery-3.5.1/jquery-3.5.1.js"></script>
    <script type="text/javascript">
        function calc() {

            let num1 = $("#num1").val();
            let num2 = $("#num2").val();
            let sig = $("#sig").val();
            let res = 0;
            alert(123);
            switch (sig) {
                case "+":
                    res = num1 + num2;
                    break;
                case "-":

                    res = num1 - num2;
                    break;
                case "*":
                    res = num1 * num2;
                    break;
                case "/":
                    if (num2 != 0) {
                        res = num1 / num2;
                    } else {
                        alert("分母不能为0");
                    }
                    break;
                default:
                    alert("运算符错误");
                    break;
            }document.getElementById("res").value = res;
        }
    </script>

</body>

</html>